#!/usr/bin/env python
# -*- coding: utf-8 -*-
# title       :
# author      : jarry
import sys
from imp import reload

import TyhooToolCook.data.ui_element.ToolCookWindow as tcw

reload(tcw)


#from icons_rc import *

# my_ui = tcw.ToolCookWindow()
# my_ui.show()

# add license check
#import THLicense.CheckLicense as cl
#cl.CheckLicense()

def run(dockAE=True):
    if sys.argv[0].endswith('maya.exe'):
        # run in maya
        # import weakref
        import maya.cmds as cmds
        # import maya.OpenMayaUI as omui
        import TyhooToolCook.libs.dockToAEWindow as dae
        import TyhooToolCook.libs.getMayaWindow as gmw
        reload(dae)
        reload(gmw)

        name = 'TyhooToolCook'
        if dockAE:
            if cmds.window(name, q=1, ex=1):
                cmds.deleteUI(name)
            ui = dae.dockToAEWindow(tcw.ToolCookWidget, name, name)
            ui.show()
        else:
            ui = tcw.ToolCookWindow(parent=gmw.getMayaWindow())
            ui.show()
            # if pm.dockControl(name, q=1, ex=1):
            #     cmds.deleteUI(name)
            #
            # pm.dockControl(name, area='right',
            #                content=ui.objectName(),
            #                width=370,
            #                label=ui.objectName(),
            #                allowedArea=['right', 'left'])
    else:
        # run in standard
        # app = QApplication([])
        my_ui = tcw.ToolCookWindow()
        my_ui.show()
        # app.exec_()


if __name__ == '__main__':
    run()
